// src/api/merchandise.ts
// 商品相关接口
import request from '@/utils/request';
import type {
  AddGoodsRequest,
  GoodsResponse,
  GetGoodsListParams,
  GoodsListResponse,
  DeleteGoodsRequest,
  DeleteGoodsResponse,
  EditGoodsRequest
} from './types/merchandise';

enum GoodsAPI {
  ADD_GOODS = '/shop/meal',    // 新增商品
  EDIT_GOODS = '/shop/meal', // 修改商品
  GET_GOODS_LIST = '/shop/meal', // 查询商品
  DELETE_GOODS = '/shop/meal' // 删除商品
}

/**
 * 新增商品
 * @param data 商品数据
 */
export const addGoods = (data: AddGoodsRequest) => {
  return request.post<GoodsResponse,GoodsResponse>(GoodsAPI.ADD_GOODS, data);
};
/**
 * 修改商品
 * @param data 商品数据
 */
export const editGoods = (data: EditGoodsRequest) => {
  return request.put<GoodsResponse,GoodsResponse>(GoodsAPI.EDIT_GOODS, data);
};
/**
 * 查询商品列表
 * @param params 查询参数
 */
export const getGoodsList = <T = GoodsListResponse>(params: GetGoodsListParams) => {
  return request.get<T,T>(GoodsAPI.GET_GOODS_LIST, { params });
};

/**
 * 删除商品
 * @param data 商品ID
 */
export const deleteGoods = (data: DeleteGoodsRequest) => {
  return request.delete<DeleteGoodsResponse,DeleteGoodsResponse>(GoodsAPI.DELETE_GOODS, { data });
};
